package com.pactera.madp.cp.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.pactera.madp.cp.api.entity.RadarContactEntity;
import com.pactera.madp.cp.mapper.RadarContactMapper;
import com.pactera.madp.cp.service.RadarContactService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;

@Slf4j
@Service
@AllArgsConstructor
public class RadarContactServiceImpl extends ServiceImpl<RadarContactMapper, RadarContactEntity> implements RadarContactService {

    @Override
    public String getAvatarByCustNo(String custNo) {
        List<RadarContactEntity> avatarList = baseMapper.selectList(new LambdaQueryWrapper<RadarContactEntity>()
                .select(RadarContactEntity::getHeadimgurl)
                .eq(RadarContactEntity::getCustNo, custNo));
        if (avatarList.isEmpty()) {
            return "";
        } else {
            return avatarList.get(0).getHeadimgurl();
        }
    }
}
